package cn.iocoder.yudao.framework.business.eligibility.pojo.po;

import cn.iocoder.yudao.framework.business.basic.pojo.po.MemberScopeEntity;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.time.LocalDateTime;

/**
 * 用户身份资格 DO
 *
 * @author 山野羡民
 */
@Data
@NoArgsConstructor
public abstract class EligibilityUserEntity extends MemberScopeEntity {

    /**
     * 累计购买金额
     */
    private Integer cumulativePrice;
    /**
     * 累计购买次数
     */
    private Integer purchaseCount;
    /**
     * 累计购买天数
     */
    private Integer daysCount;
    /**
     * 最近购买天数
     */
    private Integer lastDays;
    /**
     * 入驻时间
     */
    private LocalDateTime enterTime;
    /**
     * 到期时间
     */
    private LocalDateTime expireTime;

    /**
     * 是否有效
     */
    public boolean isValid() {
        return getPurchaseCount() > 0 && getExpireTime().isAfter(LocalDateTime.now());
    }

}